<template>
  <div>
    <div class="list-table">
      <el-form ref="queryForm" :model="queryParams" :inline="true">
        <el-form-item :label="$t('项目名称')" prop="dealName">
          <el-input
            v-model="queryParams.dealName"
            :placeholder="$t('项目名称')"
            clearable
            @keyup.enter.native="queryHandle"
          />
        </el-form-item>
        <el-form-item :label="$t('基金名称')" prop="fundName">
          <el-input
            v-model="queryParams.fundName"
            :placeholder="$t('基金名称')"
            clearable
            @keyup.enter.native="queryHandle"
          />
        </el-form-item>
        <el-form-item :label="$t('估值差异')" prop="investmentName">
          <el-select v-model="queryParams.difference" :placeholder="$t('估值差异')" clearable size="small">
            <el-option v-for="dict in differenceOptions" :key="dict.dictValue" :label="$t(dict.dictLabel)" :value="dict.dictValue" />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="queryHandle">{{ $t('搜索') }}</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t('重置') }}</el-button>
        </el-form-item>
      </el-form>

      <el-table v-loading="loading" tooltip-effect="darkTable" :data="dataList" border>
        <el-table-column :label="$t('项目名称')" align="center" prop="dealName" show-overflow-tooltip min-width="150">
          <template slot-scope="scope">
            <router-link target="_blank" to="" class="link_a">{{ scope.row.dealName }}</router-link>
          </template>
        </el-table-column>
        <el-table-column :label="$t('基金名称')" align="center" prop="fundName" show-overflow-tooltip min-width="150">
          <template slot-scope="scope">
            <router-link target="_blank" to="" class="link_a">{{ scope.row.fundName }}</router-link>
          </template>
        </el-table-column>
        <el-table-column :label="$t('投资金额')" align="center" prop="investmentAmount" show-overflow-tooltip min-width="120">
          <template slot-scope="scope">
            <span class="money-text">{{ moneyFormat(scope.row.investmentAmount) }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('持股比例(%)')" align="center" prop="latestShareholdingRatio" show-overflow-tooltip min-width="120">
          <template slot-scope="scope">
            <span>{{ moneyFormat(scope.row.latestShareholdingRatio) }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('估值时间')" align="center" prop="valuationTime" show-overflow-tooltip min-width="100">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.valuationTime) }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('项目估值') + $t('金额单位')" align="center" prop="projectValuation" show-overflow-tooltip min-width="120">
          <template slot-scope="scope">
            <span class="money-text">{{ moneyFormat(scope.row.projectValuation, 'w') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('公司整理估值') + $t('金额单位')" align="center" prop="organizeValuation" show-overflow-tooltip min-width="120">
          <template slot-scope="scope">
            <span class="money-text" :class="{'down':scope.row.type === 0,'up':scope.row.type === 1}">
              {{ moneyFormat(scope.row.organizeValuation, 'w') }}
              <i class="iconfont" :class="{'icon-a-down':scope.row.type === 0,'icon-a-up':scope.row.type === 1}" style="font-size: 12px;" />
            </span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('估值差异')" align="center" prop="difference" min-width="100">
          <template slot-scope="scope">
            <span class="pointer" :class="{'down':scope.row.difference === '1','up':scope.row.difference === '3'}" @click="onClick(scope.row)">{{ differenceFormat(scope.row.difference) }}</span>
          </template>
        </el-table-column>

      </el-table>

      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>

    <el-dialog :title="title" :visible.sync="formOpen" :close-on-click-modal="false" :lock-scroll="false" custom-class="dialogForm" append-to-body>
      <el-table v-loading="loading" tooltip-effect="darkTable" :data="dialogDataList" border>
        <el-table-column :label="$t('项目名称')" align="center" prop="dealName" show-overflow-tooltip min-width="150">
          <template slot-scope="scope">
            <router-link target="_blank" to="" class="link_a">{{ scope.row.dealName }}</router-link>
          </template>
        </el-table-column>
        <el-table-column :label="$t('基金名称')" align="center" prop="fundName" show-overflow-tooltip min-width="150">
          <template slot-scope="scope">
            <router-link target="_blank" to="" class="link_a">{{ scope.row.fundName }}</router-link>
          </template>
        </el-table-column>
        <el-table-column :label="$t('投资金额')" align="center" prop="investmentAmount" show-overflow-tooltip min-width="120">
          <template slot-scope="scope">
            <span class="money-text">{{ moneyFormat(scope.row.investmentAmount) }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('持股比例(%)')" align="center" prop="latestShareholdingRatio" show-overflow-tooltip min-width="120">
          <template slot-scope="scope">
            <span>{{ moneyFormat(scope.row.latestShareholdingRatio) }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('估值时间')" align="center" prop="valuationTime" show-overflow-tooltip min-width="100">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.valuationTime) }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('项目估值') + $t('金额单位')" align="center" prop="projectValuation" show-overflow-tooltip min-width="120">
          <template slot-scope="scope">
            <span class="money-text">{{ moneyFormat(scope.row.projectValuation, 'w') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('公司整理估值') + $t('金额单位')" align="center" prop="organizeValuation" show-overflow-tooltip min-width="120">
          <template slot-scope="scope">
            <span class="money-text" :class="{'down':scope.row.type === 0,'up':scope.row.type === 1}">
              {{ moneyFormat(scope.row.organizeValuation, 'w') }}
              <i class="iconfont" :class="{'icon-a-down':scope.row.type === 0,'icon-a-up':scope.row.type === 1}" style="font-size: 12px;" />
            </span>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template>

<script>
export default {
  components: {
  },
  data() {
    return {
      loading: false,
      total: 0,
      title: '',
      differenceOptions: [
        { dictLabel: '低', dictValue: '1' },
        { dictLabel: '中', dictValue: '2' },
        { dictLabel: '高', dictValue: '3' }
      ],
      dataList: [
        { dealName: '易募立融', fundName: '孚腾一期', investmentAmount: 1000, latestShareholdingRatio: 15, valuationTime: '2024-03-31', projectValuation: 12000000, organizeValuation: 20000000, difference: '1' },
        { dealName: '易尽调', fundName: '孚腾一期', investmentAmount: 1000, latestShareholdingRatio: 15, valuationTime: '2024-03-31', projectValuation: 12000000, organizeValuation: 20000000, difference: '2' },
        { dealName: '易募立融', fundName: '中国国新控股', investmentAmount: 1000, latestShareholdingRatio: 15, valuationTime: '2024-03-31', projectValuation: 12000000, organizeValuation: 25000000, difference: '3', type: 1 },
        { dealName: '三只松鼠', fundName: '中国国新控股', investmentAmount: 1000, latestShareholdingRatio: 15, valuationTime: '2024-03-31', projectValuation: 12000000, organizeValuation: 20000000, difference: '2' },
        { dealName: '北京新能环保', fundName: '中国国新控股', investmentAmount: 1000, latestShareholdingRatio: 15, valuationTime: '2024-03-31', projectValuation: 12000000, organizeValuation: 20000000, difference: '2', type: 0 },
        { dealName: '字节跳动', fundName: '孚腾一期', investmentAmount: 1000, latestShareholdingRatio: 15, valuationTime: '2024-03-31', projectValuation: 12000000, organizeValuation: 20000000, difference: '2' },
        { dealName: '抖音', fundName: '孚腾一期', investmentAmount: 1000, latestShareholdingRatio: 15, valuationTime: '2024-03-31', projectValuation: 12000000, organizeValuation: 20000000, difference: '2' },
        { dealName: '小红书', fundName: '孚腾一期', investmentAmount: 1000, latestShareholdingRatio: 15, valuationTime: '2024-03-31', projectValuation: 12000000, organizeValuation: 20000000, difference: '2' }
      ],
      dialogDataList: [
        { dealName: '易募立融', fundName: '孚腾一期', investmentAmount: 1000, latestShareholdingRatio: 15, valuationTime: '2024-03-31', projectValuation: 12000000, organizeValuation: 20000000, difference: '1' },
        { dealName: '易募立融', fundName: '中国国新控股', investmentAmount: 1000, latestShareholdingRatio: 15, valuationTime: '2024-03-31', projectValuation: 12000000, organizeValuation: 25000000, difference: '3', type: 1 }
      ],
      formOpen: false,
      queryParams: {
        dealId: this.$route.query.id,
        investmentName: undefined,
        dealName: undefined,
        companyName: undefined,
        pageNum: 1,
        pageSize: 10
      }
    }
  },
  created() {
  },
  mounted() {
  },
  methods: {
    getList() {
    },
    differenceFormat(row) {
      return this.selectDictLabel(this.differenceOptions, row)
    },
    onClick(row) {
      if (row.difference !== '2') {
        this.title = row.dealName
        this.formOpen = true
      }
    },
    /** 搜索按钮操作 */
    queryHandle() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm')
      this.queryHandle()
    }
  }
}
</script>
<style scoped lang="scss">
.down{
  color: green;
}
.up{
  color: red;
}
</style>
